This notebook summarizes the realtime-kinetic measurements.
Before running this notebook, you need to pre-process the data with:
This pre-processing analyzes the measurement data files, compute the moving-window slices, the number of bursts and fits the population fractions. All results are saved as TXT in the results folder.
The present notebook loads these results and presents a summary.
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from pathlib import Path
from scipy.stats import linregress
In [2]:
dir_ = r'C:\Data\Antonio\data\8-spot 5samples data\2013-05-15/'
filenames = [str(f) for f in Path(dir_).glob('*.hdf5')]
filenames
keys = [f.stem.split('_')[0] for f in Path(dir_).glob('*.hdf5')]
keys
filenames_dict = {k: v.stem for k, v in zip(keys, Path(dir_).glob('*.hdf5'))}
filenames_dict
Out[2]:
In [3]:
def _filename_fit(idx, method, window, step):
return 'results/%s_%sfit_ampl_only__window%ds_step%ds.txt' % (filenames_dict[idx], method, window, step)
def _filename_nb(idx, window, step):
return 'results/%s_burst_data_vs_time__window%ds_step%ds.txt' % (filenames_dict[idx], window, step)
In [4]:
def process(meas_id):
methods = ['em', 'll', 'hist']
fig_width = 14
fs = 18
def savefig(title, **kwargs):
plt.savefig("figures/Meas%s %s" % (meas_id, title))
bursts = pd.DataFrame.from_csv(_filename_nb(meas_id, window=30, step=1))
nbm = bursts.num_bursts.mean()
nbc = bursts.num_bursts_detrend
print("Number of bursts (detrended): %7.1f MEAN, %7.1f VAR, %6.3f VAR/MEAN" %
(nbm, nbc.var(), nbc.var()/nbm))
fig, ax = plt.subplots(figsize=(fig_width, 3))
ax.plot(bursts.tstart, bursts.num_bursts)
ax.plot(bursts.tstart, bursts.num_bursts_linregress, 'r')
title = 'Number of bursts - Full measurement'
ax.set_title(title, fontsize=fs)
savefig(title)
fig, ax = plt.subplots(figsize=(fig_width, 3))
ax.plot(bursts.tstart, bursts.num_bursts_detrend)
ax.axhline(nbm, color='r')
title = 'Number of bursts (detrended) - Full measurement'
ax.set_title(title, fontsize=fs)
savefig(title)
params = {}
for window in (5, 30):
for method in methods:
p = pd.DataFrame.from_csv(_filename_fit(meas_id, method=method,
window=window, step=1))
params[method, window, 1] = p
meth = 'em'
fig, ax = plt.subplots(figsize=(fig_width, 3))
ax.plot('kinetics', data=params[meth, 5, 1], marker='h', lw=0, color='gray', alpha=0.2)
ax.plot('kinetics', data=params[meth, 30, 1], marker='h', lw=0, alpha=0.5)
ax.plot('kinetics_linregress', data=params[meth, 30, 1], color='r')
title = 'Population fraction - Full measurement'
ax.set_title(title, fontsize=fs)
savefig(title)
px = params
print('Kinetics 30s: %.3f STD, %.3f STD detrended.' %
((100*px[meth, 30, 1].kinetics).std(),
(100*px[meth, 30, 1].kinetics_linregress).std()))
In [5]:
process(meas_id = '7d')
In [6]:
process(meas_id = '12d')
In [7]:
process(meas_id = '17d')
In [ ]: